package com.bwie.system.controller;

import com.bwie.common.domain.Delivery;
import com.bwie.common.domain.Orders;
import com.bwie.common.result.Result;
import com.bwie.system.service.OrdersService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("orders")
public class OrdersController {
    @Autowired
    private OrdersService ordersService;
    /**
     * 订单列表
     */
    @PostMapping("ordersList")
    private Result ordersList(@RequestBody Orders orders){
      PageInfo<Orders> pageInfo = ordersService.ordersList(orders);
      return Result.success(pageInfo);

    }
    /**
     * 批量删除
     */
    @PostMapping("delAll")
    private Result delAll(@RequestBody List<Integer> ordersIds){
        ordersService.delAll(ordersIds);
        return Result.success();
    }
    /**
     * 订单详情
     */
     @GetMapping("findOrder/{ordersId}")

    private Result findOrder(@PathVariable Integer ordersId){
        Orders orders = ordersService.findOrder(ordersId);
        return Result.success(orders);
     }
    /**
     * 更新状态
     */
    @GetMapping("updOrderState/{ordersId}")
    private Result updOrderState(@PathVariable Integer ordersId){
        ordersService.updOrderState(ordersId);
        return Result.success();
    }
    /**
     * 回显配送信息
     */
    @GetMapping("findDelivery/{deliveryId}")
    private Result findDelivery(@PathVariable Integer deliveryId){
      Delivery delivery = ordersService.findDelivery(deliveryId);
        return Result.success(delivery);
    }



}
